﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
// This part is added due to homework.
using System.Globalization;
using System.Threading;


namespace IDE_week2_Forms_project
{
    public partial class Form1 : Form
    {
        // Remark: is it possible not to use global parameter?
        // this is used for language swift.
        bool langFlag = false;

        public Form1()
        {
            //Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-Hans");
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Icon icon1 = new Icon("E:/IDE/Assignment2/IDE_week2_Solution/IDE_week2_Forms_project/Resources/Icon1.ico");
            Icon icon1 = new Icon("../../Resources/Icon1.ico");
            this.Icon = icon1;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2() ;
            form2.Visible = true;
            //form2.Show(); 
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Icon = default(Icon);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            int[] numbers = new int[10];
            Class1.MakeRandomNumber(numbers);
            label1.Text = numbers[0] + ", " + numbers[1] + ", " + numbers[2];
        }

        private void ChangeLanguage(string lang)
        {
            foreach (Control c in this.Controls)
            {
                ComponentResourceManager resources =
                      new ComponentResourceManager(typeof(Form1));
                resources.ApplyResources(c, c.Name, new CultureInfo(lang));
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            if(langFlag)
            {
                ChangeLanguage(CultureInfo.CurrentUICulture.Name);
            }
            else
            {
                ChangeLanguage("zh-Hans");
            }
            langFlag = !langFlag;
        }
    }
}
